package com.openlogic.common.security.entity;

import javax.validation.constraints.Size;

import org.noear.solon.validation.annotation.NotBlank;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import com.openlogic.common.core.constants.system.AuthorityConstants;
import com.openlogic.common.core.web.domain.BaseEntity;

import cn.hutool.core.util.StrUtil;

/**
 * @ClassName: SysEnterprise
 * @Description: 企业 数据对象
 * @author weiyongpeng
 * @date 2025年1月30日 下午9:06:02
 */
@Table("te_tenant")
public class SysTenantEntity extends BaseEntity {

	private static final long serialVersionUID = 1L;

	/** Id */
	@Id("id")
	private String id;

	/** 名称 */
	@Column(value = "name")
	private String name;

	/** 策略Id */
	@Column("strategy_id")
	private String strategyId;

	/** 系统名称 */
	@Column("system_name")
	private String systemName;

	/** 企业名称 */
	@Column("nick")
	private String nick;

	/** 状态（0 启用 1 禁用） */
	@Column("status")
	private String status;

	/** 企业logo */
	@Column("logo")
	private String logo;

	/** 超管租户（Y是 N否） */
	@Column("is_lessor")
	private String isLessor;

	/** 企业账号修改次数 */
	@Column("name_frequency")
	private Long nameFrequency;

	/** 默认企业（Y是 N否） */
	@Column("is_default")
	private String isDefault;

	public String getStrategyId() {
		return strategyId;
	}

	public void setStrategyId(String strategyId) {
		this.strategyId = strategyId;
	}

//    @Xss(message = "企业账号不能包含脚本字符")
	@NotBlank(message = "企业账号不能为空")
	@Size(max = 30, message = "企业账号长度不能超过30个字符")
	public String getName() {
		return name;
	}

//    @Xss(message = "系统名称不能包含脚本字符")
	@NotBlank(message = "系统名称不能为空")
	@Size(max = 30, message = "系统名称长度不能超过30个字符")
	public String getSystemName() {
		return systemName;
	}

	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}

//    @Xss(message = "企业名称不能包含脚本字符")
	@NotBlank(message = "企业名称不能为空")
	@Size(max = 30, message = "企业名称长度不能超过30个字符")
	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	public String getIsLessor() {
		return isLessor;
	}

	public void setIsLessor(String isLessor) {
		this.isLessor = isLessor;
	}

	public Long getNameFrequency() {
		return nameFrequency;
	}

	public void setNameFrequency(Long nameFrequency) {
		this.nameFrequency = nameFrequency;
	}

	public String getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(String isDefault) {
		this.isDefault = isDefault;
	}

	public boolean isAdmin() {
		return isAdmin(getIsLessor());
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static boolean isAdmin(String isLessor) {
		return StrUtil.equals(AuthorityConstants.TenantType.ADMIN.getCode(), isLessor);
	}

	@Override
	public String toString() {
		return "SysEnterpriseEntity [id=" + id + ", name=" + name + ", strategyId=" + strategyId + ", systemName="
				+ systemName + ", nick=" + nick + ", status=" + status + ", logo=" + logo + ", isLessor=" + isLessor
				+ ", nameFrequency=" + nameFrequency + ", isDefault=" + isDefault + "]";
	}

}
